<template>
  <div class="wrap">
    <div class="list">
      <div class="item">
        <input type="text" placeholder="请输入姓名" />
        <div class="first">
          <img src="../assets/order.png" class="add-icon" alt />
        </div>
      </div>
      <div class="item">
        <input type="text" placeholder="请输入手机号" />
      </div>
      <div class="item" @click="state = true">
        <p>{{address?address:'请选择地址'}}</p>
      </div>
      <div class="item">
        <input type="text" placeholder="请输入街道地址" />
      </div>
      <div class="btm">
        <img src="../assets/select.png" aplt />
        <p>保存到地址簿</p>
      </div>
      <div class="textParde">
        <textarea name id="areat" cols="30" rows="10"></textarea>
        <p>识别解析</p>
      </div>
      <p class="btn" @click="next">确定</p>
    </div>
    <van-popup v-model="state" position="bottom" :style="{ height: '40%' }">
      <van-area :area-list="areaList" @confirm="confirm" @cancel="state = false" />
    </van-popup>
    
  </div>
</template>
<style lang="scss" scoped>
.list {
  padding-top: 0.8rem;
}
.item {
  height: 1.2rem;
  width: 8.16rem;
  margin: 0 auto;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  input,
  p {
    color: #999;
    font-size: 0.32rem;
    line-height: 1.2rem;
    outline: none;
    border: none;
    flex: 2;
    text-align: left;
  }
  input::-webkit-input-placeholder {
    color: #999;
    font-size: 0.32rem;
  }
  .first {
    height: 0.586667rem;
    border-left: 1px solid #e5e5e5;
    width: 1.066667rem;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .add-icon {
    width: 0.44rem;
    height: 0.493333rem;
    display: block;
  }
}
.btm {
  display: flex;
  align-items: center;
  height: 1.2rem;
  width: 8.16rem;
  margin: 0 auto;
  img {
    width: 0.453333rem;
    height: 0.453333rem;
    display: block;
    margin-right: 0.266667rem;
  }
  p {
    color: #999;
    font-size: 0.32rem;
  }
}
.textParde {
  margin: 0.4rem auto 0;
  width: 8.16rem;
  height: 2.933333rem;
  border: 1px solid #e5e5e5;
  border-radius: 0.266667rem;
  #areat {
    border: none;
    outline: none;
    width: 90%;
    display: block;
    height: 60%;
    margin: 10px auto 10px;
  }
  p {
    color: #719BEF;
    font-size: 0.293333rem;
    text-align: right;
    display: block;
    margin-right: 15px;
  }
}
.btn {
  width: 8.16rem;
  height: 1.066667rem;
  margin: 4rem auto 0;
  background: #719BEF;
  color: #fff;
  font-size: 0.48rem;
  text-align: center;
  line-height: 1.066667rem;
  border-radius: 0.266667rem;
}
</style>
<script>
import { Area } from "vant";
import areaList from "../utils/area";
import { Dialog } from "vant";

export default {
  data() {
    return {
      value: [],
      address: "",
      state: false,
      areaList: null
    };
  },
  created() {
    document.title = "填写地址";
    this.areaList = areaList;
  },
  methods: {
        next() {
      Dialog.alert({
        title: "提示",
        message: "添加成功"
      }).then(() => {
        this.$router.replace("/");
      });
    },
    confirm(e){
      this.state = false
      let a = []
      e.map(item=>{
       a.push(item.name)
      })
      this.address = a.toString()
    }
  }
};
</script>